<?php
namespace app\admin\controller;
use think\Controller;
class Base extends Controller{
    //基类判断是否登陆
    public $admin;
    public $left;
    public $default=[
        "Indexindex" //登陆后不需要权限也能访问
    ];
    
    public function _initialize() {
        
        $controller=request()->controller();
        $action=request()->action();
        
        
        
        //判断用来登陆的
       $islogin=$this->isLogin();
        if(!$islogin){
            $this->redirect(url("login/index"));
        }
        //判断是否有权限
        
        
        
    }
    //判断是否登陆
    public function isLogin(){
        $user=$this->getLoginUser();
        if($user && $user->aid){
            return true;
        }
        return false;
    }
    //获取登陆用户的信息
    public function getLoginUser(){
        if(!$this->admin){
            $this->admin=session("Admin","","admin");
        }
        return $this->admin;
    }
 
    
}
